package com.company.Sort;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;

/**
 * @author VX5
 * @Title: MJC
 * @ProjectName DataStructure
 * @Description: TODO
 * @date ${DAT}15:39
 */
public class SelectSort2 {
    public static void main(String[] args) {
        int[] arr = new int[80000];
        for (int i = 0; i < 80000; i++){
            arr[i] = (int)(Math.random()*80000);
        }
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd: HH : mm : ss");
        System.out.println(format.format(date));
        getSort(arr);
        Date date2 = new Date();
        SimpleDateFormat format2 = new SimpleDateFormat("yyyy-mm-dd: HH : mm : ss");
        System.out.println(format2.format(date2));
//        int[] arr = {10,6,5,5,2,10};
//        System.out.println(Arrays.toString(getSort(arr)));
    }

    public static int[] getSort(int[] arr){
        for (int i = 0; i < arr.length-1; i++){
            int temp = i;
            int min = arr[i];
            for (int j = i + 1;j < arr.length; j++){
//                if (arr[j]<arr[i]){//该方法时每次都要交换一次、就变成了冒泡
//                    temp = arr[i];
//                    arr[i] = arr[j];
//                    arr[j] = temp;
//                }
                if (arr[j]>min){
                    min = arr[j];
                    temp = j;
                }
            }
            if (temp != i){
                arr[temp] = arr[i];
                arr[i] = min;
            }
        }
        return arr;
    }
}
